package org.boot.ssm.wxshop.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * @program: wxshop
 * @description: 动态验证码及时间转换工具
 * @author: 刘涛
 * @create: 2018-03-22 20:30
 **/
public class RandomUtil {

    /**
     * 获取随机订单号
     *
     * @return
     */
    public static String getRandomOrderNum() {
        SimpleDateFormat simpleDateFormat;
        simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
        Date date = new Date();
        String str = simpleDateFormat.format(date);
        return str + getRandomNum();
    }


    /**
     * 获取五位随机数
     * @return
     */
    public static String getRandomNum(){
        Random random = new Random();
        int rannum = (int) (random.nextDouble() * (99999 - 10000 + 1)) + 10000;
        return Integer.toString(rannum);
    }


    public static void main(String[] args) {

        System.out.println(getRandomOrderNum());
    }


}
